<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DashboardDataCheck</title>
	<link REL="SHORTCUT ICON" HREF="../../../../../static/favicon.ico"/>
	<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
	<div id="pageTitle" align="center" style="font: bold; font-size: 1.875rem;">Dashboard Data Check</div>
	<div id="envConfig" align="center">
		<div style="position: relative; margin-top: 40px;">
			<div id="environment" style="position: relative; margin-top: 20px; display: inline;">
			    Environment：
			    <select id="environmentSelect" style="font-size:20px">
			        <option value="Test">Test</option>
			        <option value="UAT" selected="selected">UAT</option>
			        <option value="Stable">Stable</option>
			    </select>
			</div>
			<div id="country" style="position: relative; margin-top: 20px; margin-left: 30px; display: inline;">
			    Country：
			    <select id="countrySelect" style="font-size:20px">
			        <option value="Thailand" selected="selected">Thailand</option>
			        <option value="Indonesia">Indonesia</option>
			    </select>
			</div>
		</div>
		<div style="position: relative; margin-top: 40px;">
			<div id="source" style="position: relative; margin-top: 40px; margin-left: 30px; display: inline;">
			    Module：
			    <select id="sourceSelect" style="font-size:20px">
			        <option value="all" selected="selected">ALL of Dashboard</option>
			        <option value="dailyKpi">Daily KPI</option>
			        <option value="messengerTask">Messenger Task</option>
					<option value="salesOrder">Sales Order</option>
					<option value="paymentRefundNotFinished">Payment refund not finished</option>
					<option value="purchaseOrder">Purchase Order</option>
					<option value="supplierManagement">Supplier Management</option>
					<option value="serviceLevelFailed">Service Level Failed</option>
					<option value="finance">Finance</option>
					<option value="EMCSOrder">EMCS Order</option>
					<option value="EMCSOrderException">EMCS Order Exception</option>
					<option value="customer">Customer</option>
					<option value="quotation">Quotation</option>
			    </select>
			</div>
			<div id="ThreadCount" style="position: relative; margin-top: 40px; margin-left: 30px; display: inline;">
			    ThreadCount：<input id="ThreadCountInput" type="number" placeholder="Please input integer" width="50" height="28" value="1" style="font-size:20px; width: 200px; text-align: center;">
			</div>
		</div>
	</div>
	<div id="btn" align="right">
		<input type="button" value="StartCheck" style="font-size:20px; background-color: #58ACFA; border-radius:10px;" onclick="checkData()"/>
	</div>
    <div id="checkData" style="position: relative; margin-top: 20px;">
		<div id="DailyKPI" style="background-color: lightblue;">
			<div id="DailyKPITitle" style="font-size: 1.5625rem; color: black;">Daily KPI</div>
			<div id="DailyKPIData"></div>
		</div>
		<div id="MessengerTask" style="background-color: lightpink;">
			<div id="MessengerTaskTitle" style="font-size: 1.5625rem; color: black;">Messenger Task</div>
			<div id="MessengerTaskData"></div>
		</div>
		<div id="SalesOrder" style="background-color: lightgreen;">
			<div id="SalesOrderTitle" style="font-size: 1.5625rem; color: black;">Sales Order</div>
			<div id="SalesOrderData"></div>
		</div>
		<div id="PaymentRefundNotFinished" style="background-color: lightsalmon;">
			<div id="PaymentRefundNotFinishedTitle" style="font-size: 1.5625rem; color: black;">Payment refund not finished(for PO by Changing Supplier)</div>
			<div id="PaymentRefundNotFinishedData"></div>
		</div>
		<div id="PurchaseOrder" style="background-color: lightblue;">
			<div id="PurchaseOrderTitle" style="font-size: 1.5625rem; color: black;">Purchase Order</div>
			<div id="PurchaseOrderData"></div>
		</div>
		<div id="SupplierManagement" style="background-color: lightpink;">
			<div id="SupplierManagementTitle" style="font-size: 1.5625rem; color: black;">Supplier Management</div>
			<div id="SupplierManagementData"></div>
		</div>
		<div id="ServiceLevelFailed" style="background-color: lightgreen;">
			<div id="ServiceLevelFailedTitle" style="font-size: 1.5625rem; color: black;">Service Level Failed</div>
			<div id="ServiceLevelFailedData"></div>
		</div>
		<div id="Finance" style="background-color: lightsalmon;">
			<div id="FinanceTitle" style="font-size: 1.5625rem; color: black;">Finance</div>
			<div id="FinanceData"></div>
		</div>
		<div id="EMCSOrder" style="background-color: lightblue;">
			<div id="EMCSOrderTitle" style="font-size: 1.5625rem; color: black;">EMCS Order</div>
			<div id="EMCSOrderData"></div>
		</div>
		<div id="EMCSOrderException" style="background-color: lightpink;">
			<div id="EMCSOrderExceptionTitle" style="font-size: 1.5625rem; color: black;">EMCS Order Exception</div>
			<div id="EMCSOrderExceptionData"></div>
		</div>
		<div id="Customer" style="background-color: lightgreen;">
			<div id="CustomerTitle" style="font-size: 1.5625rem; color: black;">Customer</div>
			<div id="CustomerData"></div>
		</div>
		<div id="Quotation" style="background-color: lightsalmon;">
			<div id="QuotationTitle" style="font-size: 1.5625rem; color: black;">Quotation</div>
			<div id="QuotationData"></div>
		</div>
    </div>
	<script>
		window.alert = function(name){
		
		    var iframe = document.createElement("IFRAME");
		    iframe.style.display="none";
		    iframe.setAttribute("src", 'data:text/plain,');
		    document.documentElement.appendChild(iframe);
		    window.frames[0].window.alert(name);
		    iframe.parentNode.removeChild(iframe);
		};
		
		function checkData(){
			environment = document.getElementById("environmentSelect").value
			country = document.getElementById("countrySelect").value
			sourceType = document.getElementById("sourceSelect").value
			threadCount = document.getElementById("ThreadCountInput").value
			if(parseInt(threadCount) === 0){
				alert("Order count must gigger than 0, please input again! ");
				return;
			}
			else if(parseInt(threadCount) < 0){
				alert("Order count must gigger than 0, please input again! ");
				return;
			}
			else{
				$.ajax({
				    url: "http://0.0.0.0:80/data/tools/dataCheck/dashboardData",
				    type: "POST",
				    data: {
						"environment": environment,
						"country": country,
						"sourceType": sourceType,
						"threadCount": threadCount
				    },
				    dataType: "json",
				    success: function( result ) {
						console.log(result);
						
				    }
				});
			}
		}
	</script>
</body>
</html>